﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SeleColors
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        /// <summary>
        /// 防止在窗体未加载完就触发相关事件
        /// </summary>
        private bool aIsLoading = true;
        public MainWindow()
        {
            InitializeComponent();
            aIsLoading = false;
            txt_CurrentColor.Text = "#" + colorC.HexadecimalString.Substring(3);
        }

        private void colorC_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color> e)
        {
            if (aIsLoading)
            {
                return;
            }
            txt_CurrentColor.Text = "#" + colorC.HexadecimalString.Substring(3);

            if (((bool)checkB_SetFromBackColor.IsChecked))
            {
                this.Background = new SolidColorBrush(colorC.SelectedColor);
            }
        }
    }
}
